home *** CD-ROM | disk | FTP | other *** search
- Path: lemond.sps.mot.com!sem
- From: sem@lemond.sps.mot.com (Steve Montgomery)
- Newsgroups: comp.lang.c++
- Subject: Re: Help with CEdit.GetLine
- Date: 9 Jan 96 18:17:30 GMT
- Organization: Motorola (Austin,TX)
- Message-ID: <sem.821211450@lemond.sps.mot.com>
- References: <DKw0o2.4xJ@freenet.carleton.ca>
- NNTP-Posting-Host: lemond.sps.mot.com
- X-Newsreader: NN version 6.5.0 #2 (NOV)
-
- In <DKw0o2.4xJ@freenet.carleton.ca> cf949@FreeNet.Carleton.CA (Frantisek Fisl) writes:
-
-
- >Hi experts! Could anyone post some code showing how to use the
- >CEdit.GetLine function to retrieve a line of text from an edit control in
- >a dialog box and convert it to a number?
-
- >Thanks for any help!
-
- >Frank
-
- Sounds like your using the MFC. See the online help for DoDataExchange
-
- Code in the DoDataExchange function would look like:
-
- DDX_Text(pDX, IDC_CONTROL_ID, m_IntVariable);
- DDV_MinMaxInt(pDX, m_IntVariable, 50, 5000);
-
- You need to do an UpdateData(TRUE) to exchange the data from the control
- to the variable and UpdateData(FALSE) to go the other way.
-
- The DDX function does the exchange, the DDV function validates it in a
- range from 50 to 5000 (use your own numbers). There are a whole series of
- exchange and validation functions available, and you can role your own as well.
-
- A more brute force approach would be to get the text directly from
- the control using:
- CWnd* pWnd = GetDlgItem(IDC_CONTROL_ID);
- CString sWindowText;
- pWnd->GetWindowText(sWindowText);
- m_IntVariable = atoi(sWindowText.GetBuffer(0));
-
- Hope this helps!
-
- Steve M.
-
-
- --
- Steven E. Montgomery
- Motorola, Microcontroller Software Applications
- email: sem@lemond.sps.mot.com
- voice: 512-891-7321
-